package com.itheima.map;

import java.util.HashMap;
import java.util.Map;

public class MapDemo02 {
    public static void main(String[] args) {
        Map<String,String> map = new HashMap<>();

        map.put("001","张三");
        map.put("002","李四");
        map.put("003","王五");
        map.put("004","赵六");

        //V   put(K key,V   value)
        String s = map.put("004", "aaa");
        System.out.println(s+" " +map);//赵六 {001=张三, 002=李四, 003=王五, 004=aaa}

        //V   remove(Object key)
        String s1 = map.remove("004");
        System.out.println(s1 + " "+map);//aaa {001=张三, 002=李四, 003=王五}

        //void   clear()
        /*map.clear();
        System.out.println(map);//{}*/

        //boolean containsKey(Object key)
        boolean result1 = map.containsKey("001");
        boolean result2 = map.containsKey("010");
        System.out.println(result1 + " " + result2);//true false

        //boolean containsValue(Object value)
        boolean value1 = map.containsValue("王五");
        boolean value2 = map.containsValue("111");
        System.out.println(value1 + " " + value2);//true false

        //boolean isEmpty()
        boolean empty = map.isEmpty();
        System.out.println(empty);//false

        //int size()
        System.out.println(map.size());//3

    }
}
